package com.hnevc.caoliuye;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * 遍历集合
 * 迭代器
 * [foreach]
 */
public class Example03 {
    public static void main(String[] args) {
        ArrayList list = new ArrayList();
        list.add("AAA");
        list.add("BBB");
        list.add("YY");
        list.add("yy");
        Iterator iterator = list.iterator();
        while(iterator.hasNext()){
            Object o = iterator.next();
            System.out.println(o);
        }
       for(Object o :list){
           System.out.println(o);
       }

    }
}
